package mongo.db.clients.firsts;

import java.io.FileWriter;
import java.io.IOException;
import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.MongoClient;

public class HadoopInput {

	public static void main(String[] args) throws IOException {

		try {
			MongoClient client = new MongoClient("202.191.136.234", 27017);
			DB db = client.getDB("netflowdb_15");
			DBCollection collection = db.getCollection("netflow_column_list");

		DBCursor itr = collection.find();
		System.out.println(collection.count());
		
		
		FileWriter fw = new FileWriter("/tmp/out.txt");
		 
		while ( itr.hasNext() ) {
			fw.write(itr.next().toString() + "\n");
			fw.flush();
		}
		fw.close();

		} catch (UnknownHostException e1) {
			e1.printStackTrace();
		}

		// System.out.println(readIpsFromFile());

		
	}

}
